<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_roles', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('sdk角色信息');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('game_id')->comment('游戏id')->unsigned()->default(0);
            $table->integer('channel')->comment('渠道ID')->unsigned()->default(0);
            $table->integer('user_id')->comment('账号id')->unsigned()->default(0);
            $table->integer('role_id')->comment('角色id')->unsigned()->default(0);
            $table->string('role_name', 32)->comment('角色名称')->default('');
            $table->integer('server_id')->comment('服务器id')->unsigned()->default(0);
            $table->string('server_name', 32)->comment('服务器名称')->default('');
            $table->integer('role_level')->comment('角色等级')->unsigned()->default(0);
            $table->double('total_pay_amount')->comment('总充值金额')->unsigned()->default(0);
            $table->double('total_pay_num')->comment('总充值次数')->unsigned()->default(0);
            $table->double('today_pay_amount')->comment('当天充值金额')->unsigned()->default(0);
            $table->integer('first_pay_time')->comment('首次充值时间')->unsigned()->default(0);
            $table->integer('last_pay_time')->comment('最后充值时间')->unsigned()->default(0);
            $table->integer('last_login_time')->comment('最后登录时间')->unsigned()->default(0);

            $table->index('create_time');
            $table->index('game_id');
            $table->index('channel');
            $table->index('user_id');
            $table->index('role_id');
            $table->index('server_id');
            $table->index('last_login_time');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_roles');
    }
};
